<h2>通知</h2>
<ul>
    {% for notification in notifications %}
        <li>
            <div>
                <strong>{{ notification.actor.username }}</strong> {{ notification.verb }} 
                <a href="{% url 'article:article_detail' notification.target.id %}#comment_elem_{{ notification.action_object.id }}">
                    {{ notification.target.title }}
                </a>
                <span>{{ notification.created_at|date:"Y/m/d H:i" }}</span>
            </div>
            <div style="display: flex;">
                {% if notification.action_object %}
                    <img src="{{ notification.action_object.user.profile.avatar.url }}" 
                         alt="{{ notification.action_object.user.username }}的头像" 
                         style="width: 30px; height: 30px; border-radius: 50%;">
                    <span>{{ notification.action_object.body|safe|truncatewords:10 }}</span>
                {% endif %}
            </div>
        </li>
    {% endfor %}
</ul>